module.exports = class Hook {
  constructor() {
    this.hooks = {};
  }
  
  async run(name, ...args) {
    const fns = this.hooks[name] || [];
    for (const key in fns) {
      await fns[key](...args);
    }
  }
  
  add(name, fn) {
    if (!this.hooks[name]) {
      this.hooks[name] = [fn];
    } else {
      this.hooks[name].push(fn);
    }
  }
};